const Koa = require('koa2')
const _static = require('koa-static')
const path = require('path')
const app = new Koa()
const server = require('http').createServer(app.callback()) // 引入socket服务

app.use(_static(path.resolve('./build')))

app.use(async (ctx, next) => {
	ctx.request.path === '/'
		? ((ctx.response.status = 200), ctx.response.redirect('/index.html'))
		: ctx.throw(404, 'Not found')
	await next()
})

server.listen(8080, function() {
	console.log('服务器启动，监听8080端口')
})
